﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>单据打印</title>
    <meta http-equiv="Access-Control-Allow-Origin" content="*" />
    <script type="text/javascript" src="../Scripts/QueryString.js"></script>
    <script type="text/javascript" src="../Scripts/jquery-1.7.2.min.js"></script>
    <!-- 导入配置文件. -->
    <script type="text/javascript" src="../Scripts/config.js"></script>
    <script type="text/javascript" src="../Comm/Gener.js"></script>
    <script type="text/javascript">

        $(function () {

            $("#Msg").html("<h3>正在加载请稍候....</h3>");

            var fk_bill = GetQueryString("FK_Bill");
            var nodeID = GetQueryString("FK_Node");
            var workID = GetQueryString("WorkID");
            var flowNo = GetQueryString("FK_Flow");

            //初始化页面信息
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt");
            handler.AddUrlData();
            var data = handler.DoMethodReturnString("PrintDoc_Init");
            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }
            //alert(data);
            //return;

            //如果是一个url.
            if (data.indexOf('url@') == 0) {
                var url = data.replace('url@', '');
                window.location.href = url;
                $("#Msg").html("");
                return;
            }

            //如果包含多个打印模板
            var ens = JSON.parse(data);

            var html = "<ul>";
            for (var i = 0; i < ens.length; i++) {
                var en = ens[i];
                //  html += "<li ><a href='?FK_Bill=" + en.No + "&FK_Flow=" + flowNo + "&FK_Node=" + nodeID + "&WorkID=" + workID + "'>" + en.Name + "</li>";
                html += "<li><a href='javascript:void(0);' onclick=PrintIt(" + en.No + "," + flowNo + "," + nodeID + "," + workID + ") >" + en.Name + "</li>";
            }

            html += "</ul>";

            $("#Msg").html(html);

        });

        //打印.
        function PrintIt(billNo, flowNo, nodeID, workID) {

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt");
            handler.AddPara("FK_Bill", billNo);
            handler.AddPara("FK_Flow", flowNo);
            handler.AddPara("FK_Node", nodeID);
            handler.AddPara("WorkID", workID);

            var data = handler.DoMethodReturnString("PrintDoc_Done");
            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }



            //如果是一个url.
            if (data.indexOf('url@') == 0) {

                data = data.replace('url@', '');

                if (plant == 'CCFlow') {
                    data += ",WSUrl=http://" + window.location.host + "/WF/CCForm/CCFormAPI.asmx";
                }
                else {
                    alert('还没有翻译.');
                    return;
                }

                alert(data);

                WinOpen(data);
                return;
            }
            alert(data);
        }

        //取消退回
        function Close() {

            if (window.parent != null && window.parent.returnWorkWindowClose != null) {
                window.parent.returnWorkWindowClose("取消");
            }
        }
      
    </script>
    <link href="../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div id="Msg">
    </div>
    <center>
        <input type="button" value='关闭' onclick="window.close();" />
    </center>
</body>
</html>
